package com.ruoyi.web.controller.product;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.domain.Server;
import com.ruoyi.product.domain.Product;
import com.ruoyi.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Anonymous
@Api(tags = "食物管理")
@RestController

public class ProductController {
    @Autowired
    ProductService service;
    @ApiOperation(value = "食物列表查询")
    @PostMapping("GetProductList")
    //1 食物列表查询
    public AjaxResult GetProductList(@RequestBody Product p){
        return AjaxResult.success(service.getProductList(p));
    }
    @ApiOperation(value = "查询食物详情")
    @PostMapping("selectProductList")
    //2 查询食物详情
    public AjaxResult SelectProductList(@RequestBody Product p){
        return AjaxResult.success(service.selectProductList(p));
    }
    //3 新增特产
    @ApiOperation(value = "新增食物")
    @PostMapping("addProduct")
    public AjaxResult AddProduct(@RequestBody Product p){
        return AjaxResult.success(service.addProduct(p));
    }
    //4修改食物
    @ApiOperation(value = "修改食物")
    @PostMapping("updateProduct")
    public AjaxResult UpdateProduct(@RequestBody Product p){
        service.updateProduct(p);
        return AjaxResult.success();
    }
    //5 删除食物
    @ApiOperation("删除信息")
    @GetMapping("/DeleteProduct")
    public AjaxResult DeleteProduct( int id){
        service.deleteProduct(id);
        return AjaxResult.success();
    }
    //6根据店铺姓名查询
    @ApiOperation("根据姓名查询店铺")
    @GetMapping("/QueryProductByname")
    public AjaxResult QueryProductByname(String name){
        return AjaxResult.success(service.queryProductByname(name));
    }
}
